package com.example.demo.mapper;

import com.example.demo.pojo.Address;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressMapper {
  @Insert("insert into address (name,phone,address,remarks,isDefault,userID,createTime) values (#{name},#{phone},#{address},#{remarks},#{isDefault},#{userID},#{createTime})")
   int save(Address address);
  @Update("update address set name=#{name},phone=#{phone},address=#{address},remarks=#{remarks},isDefault=#{isDefault},updateTime=#{updateTime} where addressID=#{addressID}")
    void updateById(Address address);
  @Select("select * from address where userID=#{userID}")
  List<Address> list(Integer userID);
  @Select("select * from address where userID=#{userID} AND isDefault=1")
  List<Address> listDefault(Integer userID);
  @Select("select * from address where userID=#{userID} and addressID=#{addressID}")
  List<Address> findSingle(Integer userID,Integer addressID);
  @Delete("delete from address where addressID = #{addressID}")
  void remove(Integer addressID);
}
